package com.zrrd.yunchmall.user.mapper;

import com.zrrd.yunchmall.user.entity.Menu;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 后台菜单表 Mapper 接口
 * </p>
 *
 * @author YeKong
 * @since 2024-01-15
 */
@Mapper
public interface MenuMapper extends BaseMapper<Menu> {
    /*
    根据管理员Id查询访问权限的所有菜单
    @param adminId 管理员id
    @param isHidden 查询的菜单显示状态
     */


    @Select("SELECT * FROM ums_menu  " +
            "WHERE id IN  " +
            "( " +
            "SELECT menu_id FROM ums_role_menu_relation WHERE role_id IN\n" +
            "(SELECT role_id FROM ums_admin_role_relation WHERE admin_id=#{adminId})\n" +
            ") AND hidden<>#{hidden};")
List<Menu> selectMenusByAdminId(@Param("adminId") long adminId,@Param("hidden") int isHidden);
}
